package com.fqgj.report.statistics.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.report.statistics.dao.BiAttrBlackListDao;
import com.fqgj.report.statistics.entity.BiAttrBlackListEntity;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * User: liupengpeng
 * Date: 2017-10-28
 * Time: 20:01:35.488
 */

@Repository
public class BiAttrBlackListDaoImpl extends AbstractBaseMapper<BiAttrBlackListEntity> implements BiAttrBlackListDao {


    @Autowired
    @Qualifier("sqlSessionFactory2")
    private SqlSessionFactory sqlSessionFactory;

    @Override
    public BiAttrBlackListEntity findByValueAndType(Long merchantId, Long appId, String type, String value) {
        Map<String, Object> param = new HashMap<>();
        param.put("merchantId", merchantId);
        param.put("appId", appId);
        param.put("type", type);
        param.put("name", value);
        SqlSession sqlSession = new SqlSessionTemplate(sqlSessionFactory);
        return sqlSession.selectOne(getStatement(".findByValueAndType"), param);
    }
}